//
//  BufferQueue.c
//  BufferQueue
//
//  Created by yh on 2018/4/12.
//  Copyright © 2018年 yh. All rights reserved.
//

#include "BufferQueue.h"

void q_put(struct Queue *queue,unsigned char dat){
    
    if (queue->dat_lenght == BUFFER_SIZE) {
      
        return;
    }
  
    queue->buffer[queue->tail] = dat;
    ++queue->dat_lenght;
    ++queue->tail;
    queue->tail%=BUFFER_SIZE;
    
    
}

unsigned char q_get(struct Queue *queue){
    unsigned char dat ;
    if (queue->dat_lenght == 0) {
				
        return '\0';
    }
    
    dat = queue->buffer[queue->head];
    queue->buffer[queue->head] = '\0';
    --queue->dat_lenght;
    ++queue->head;
    queue->head%=BUFFER_SIZE;
   
    return dat;
}
